package tech.daoxuan.security.core.social.qq.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;
import tech.daoxuan.security.core.properties.QQProperties;
import tech.daoxuan.security.core.properties.SecurityProperties;
import tech.daoxuan.security.core.social.qq.connect.QQConnectionFactory;

/**
 * @ClassName QQAutoConfig
 * @Description TODO
 * @Author 10983
 * @Date 2019/6/23 14:28
 * @Version 1.0
 */
@Configuration
@ConditionalOnProperty(prefix = "daoxuan.security.social.qq",name = "app-id ")
public class QQAutoConfig extends SocialAutoConfigurerAdapter {

    @Autowired
    private SecurityProperties securityProperties;
    @Override
    protected ConnectionFactory<?> createConnectionFactory() {
        QQProperties qq = securityProperties.getSocial().getQq();
        return new QQConnectionFactory(qq.getProviderId(),qq.getAppId(),qq.getAppSecret());
    }
}
